package jgl.vajra.operator.part.vehicle.viewModel;

import java.util.Map;

import jgl.vajra.operator.bean.OrderDetailsBean;
import jgl.vajra.operator.bean.OrderPaymentDetailsBean;
import jgl.vajra.operator.part.vehicle.contract.OrderDetailsContract;
import jgl.vajra.operator.part.vehicle.model.OrderDetailsModel;
import jgl.vajra.operator.widget.mvvm.factory.CreateModel;
import jgl.vajra.operator.widget.retrofithelper.rxsubscriber.ProgressObserver;

@CreateModel(OrderDetailsModel.class)
public class OrderDetailsViewModel extends OrderDetailsContract.ViewModel{

    @Override
    public void getOrderPaymentDetailsData(Map<String, Object> map) {
        mModel.getOrderPaymentDetailsData(map).subscribe(new ProgressObserver<OrderPaymentDetailsBean>(false,this) {
            @Override
            public void _onNext(OrderPaymentDetailsBean data) {
                mView.returnOrderPaymentDetailsData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void cancelOrder(Map<String, Object> map) {
        mModel.cancelOrder(map).subscribe(new ProgressObserver<String>(true, this) {
            @Override
            public void _onNext(String s) {
                mView.returnCancelOrder();
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }


    @Override
    public void getOrderDetailsData(Map<String, Object> map) {
        mModel.getOrderDetailsData(map).subscribe(new ProgressObserver<OrderDetailsBean>(false,this) {
            @Override
            public void _onNext(OrderDetailsBean data) {
                mView.returnOrderDetailsData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void getWorkingState(Map<String, Object> map) {
        mModel.getWorkingState(map).subscribe(new ProgressObserver<OrderDetailsBean>(true,this) {
            @Override
            public void _onNext(OrderDetailsBean data) {
                mView.returnOrderDetailsData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void getStartData(Map<String, Object> map) {
        mModel.getStartData(map).subscribe(new ProgressObserver<OrderDetailsBean>(false,this) {
            @Override
            public void _onNext(OrderDetailsBean data) {
                mView.returnStartData();
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }
}
